#!/bin/bash
export LANG=zh_CN.UTF-8
PRESTO_HOME=/export/server/presto/bin/presto
MYSQL_HOME=/usr/bin/mysql
HIVE_HOME=/usr/bin/hive

echo "" >> ./sqoop_liujie.log
start_time=`date +"%Y-%m-%d %H:%M:%S"`
echo "dwb create table start ${start_time}" >> ./sqoop_liujie.log

${HIVE_HOME} -S -e "
create database if not exists edu_dwb;
drop table if exists edu_dwb.dwb_stu_attendance_detail;
create table if not exists edu_dwb.dwb_stu_attendance_detail
(
    school_id              INT comment '校区id',
    subject_id             INT comment '学科id',
    class_id               INT comment '班级id',
    studying_student_count INT comment '在读班级人数',
    morning_begin_time     string comment '上午开始时间',
    morning_end_time       string comment '上午结束时间',
    afternoon_begin_time   string comment '下午开始时间',
    afternoon_end_time     string comment '下午结束时间',
    evening_begin_time     string comment '晚上开始时间',
    evening_end_time       string comment '晚上结束时间',
    student_id             INT comment '学员id',
    leave_begin_time       string comment '请假开始时间',
    leave_end_time         string comment '请假结束时间',
    morning_is_leave       int comment '上午是否请假(0:未请假,1:请假),存在请假记录时，此字段值有效',
    afternoon_is_leave     int comment '下午是否请假(0:未请假,1:请假),存在请假记录时，此字段值有效',
    evening_is_leave       int comment '晚上是否请假(0:未请假,1:请假),存在请假记录时，此字段值有效',
    morning_signin_time    string comment '上午签到时间',
    afternoon_signin_time  string comment '下午签到时间',
    evening_signin_time    string comment '晚上签到时间',
    morning_is_late        int comment '上午是否迟到(0:未迟到,1:迟到),存在签到记录时，此字段值有效',
    afternoon_is_late      int comment '下午是否迟到(0:未迟到,1:迟到),存在签到记录时，此字段值有效',
    evening_is_late        int comment '晚上是否迟到(0:未迟到,1:迟到),存在签到记录时，此字段值有效'
)partitioned by (studying_date string)
row format delimited fields terminated by '\t'
stored as orc tblproperties('orc.compress'='snappy');
"


start_time=`date +"%Y-%m-%d %H:%M:%S"`
echo "dwb create table end ${start_time}" >> ./sqoop_liujie.log
